package taskmanager;

import taskinstance.Task;

public class TaskManagerFrontTerminal extends TaskManager {
  public TaskManagerFrontTerminal(String[] allIps) {
    super(allIps);
  }
  
  public void queryTaskState() {
    synchronized (runningList) {
      System.out.println("###########################");

      System.out.println("Running Task\n");
      System.out.println("Pro\tDes\tFile");
      for (Task t : runningList) {
        if (!t.isPending()) {
          System.out.println(t.getProgress() + '\t' + t.toString());
        }
      }
      System.out.println("\n-------------------------");

      System.out.println("Pending Task\n");
      System.out.println("Des\tFile");
      for (Task t : runningList) {
        if (t.isPending()) {
          System.out.println(t);
        }
      }
      System.out.println("\n-------------------------");

      System.out.println("Complete Task\n");
      if (completeList.size() > 0) {
        System.out.println("Des\tFile");
      }
      for (Task t : completeList) {
        System.out.println(t);
      }
      System.out.println("\n-------------------------");

      System.out.println("Failed Task\n");
      if (failedList.size() > 0) {
        System.out.println("Des\tFile");
      }
      for (Task t : failedList) {
        System.out.println(t);
      }
      System.out.println("\n-------------------------");
      System.out.println("###########################\n\n");
    }
  }

  public void suspendTask(Task t) {
    t.suspend();
  }

  public void resumeTask(Task t) {
    t.resume();
  }
}
